appSkeleton.directive('functionA',
    function ($templateCache, $rootScope,$timeout) {
        return {
            //parameters
            restrict: 'AE',
            replace: true,
            template: $templateCache.get("function-A-tpl.html"),

            controller: function ($scope, $element, $location,t2iSpinnerService) {
                $scope.options = {
                    "searchfield": {
                        "visible": true,
                        "placeholder": 'Search'
                    }
                };
                $scope.attrFilter = ['sessionName'];
                $scope.attrId = 'sessionId';
                $scope.displayedItemsPerPage = 2;
                $scope.sessions=[
                    {
                        "sessionId":1,
                        "sessionName":"Session 1",
                        "firstDate":1380608870000,
                        "lastDate":1388384870000
                    },
                    {
                        "sessionId":2,
                        "sessionName":"Session 2",
                        "firstDate":1380608870000,
                        "lastDate":1388384870000
                    },
                    {
                        "sessionId":3,
                        "sessionName":"Session 3",
                        "firstDate":1380608870000,
                        "lastDate":1388384870000
                    },
                    {
                        "sessionId":4,
                        "sessionName":"Session 4",
                        "firstDate":1380608870000,
                        "lastDate":1388384870000
                    },
                    {
                        "sessionId":5,
                        "sessionName":"Session 5",
                        "firstDate":1380608870000,
                        "lastDate":1388384870000
                    },
                    {
                        "sessionId":6,
                        "sessionName":"Session 6",
                        "firstDate":1380608870000,
                        "lastDate":1388384870000
                    },
                    {
                        "sessionId":7,
                        "sessionName":"Session 7",
                        "firstDate":1380608870000,
                        "lastDate":1388384870000
                    },
                    {
                        "sessionId":8,
                        "sessionName":"Session 8",
                        "firstDate":1380608870000,
                        "lastDate":1388384870000
                    },
                    {
                        "sessionId":9,
                        "sessionName":"Session 9",
                        "firstDate":1380608870000,
                        "lastDate":1388384870000
                    },
                    {
                        "sessionId":10,
                        "sessionName":"Session 10",
                        "firstDate":1380608870000,
                        "lastDate":1388384870000
                    },
                    {
                        "sessionId":11,
                        "sessionName":"Session 11",
                        "firstDate":1380608870000,
                        "lastDate":1388384870000
                    },
                    {
                        "sessionId":12,
                        "sessionName":"Session 12",
                        "firstDate":1380608870000,
                        "lastDate":1388384870000
                    },
                    {
                        "sessionId":13,
                        "sessionName":"Session 13",
                        "firstDate":1380608870000,
                        "lastDate":1388384870000
                    }
                ]
                $scope.t2iSpinnerService = t2iSpinnerService;
                var pdfViewerScope;
                $timeout(function(){
                    var pdfViewerElementScope = angular.element('[name=pdfviewer-name]');
                    pdfViewerScope = pdfViewerElementScope.isolateScope();
                })
                //calculate absolute path
                var href = window.location.href;
                var pathName = window.location.pathname;
                var origin = href.substring(0, href.indexOf(pathName));

                //remove index.html
                pathName = pathName.replace("index.html","");
                $scope.pdfUrl = origin + pathName +'pdf-sample.pdf';

                $scope.hideButtons = [];
                $scope.hideButtons.push('print');
                $scope.hideButtons.push('open');
                $scope.hideButtons.push('download');
                $scope.pdfViewerComponent = 'bower_components/pdfViewer/viewer.html';
            },


            //data binding
            scope: {},
            link: function ($scope, $element) {
                $scope.t2iSpinnerService.stop(0);

                $timeout(function(){
                    $scope.t2iSpinnerService.start($element.find("#spinner"));

                })

            }


        };
    });
